Masthead

Raster Math

One of the most powerful things we can do with rasters is run mathematical operations on them. Some examples might include:

These and other raster calculations are performed regularly by GIS professionals.

The concept of Raster math was introduced by Dana Tomlin and Joseph Berry in the 1970's. The idea what that you could perform math on a raster on a pixel by pixel basis.

Some real-life examples where raster math was used include:

The sections below will illustrate the different types of operations we can perform on raster data: scalar with a raster, raster with a raster, functions on a raster, and boolean raster operations.

Functions on Rasters

There are a variety of functions we can apply to the pixels in a raster. Below is a tool that allows you to try a few of the functions and see the result on the pixel values and the pixels themselves.

Note: the output values are limited to 0 to 255 so they correspond directly to intensity values displayed by your monitor.

Dimensions of the raster:

 

=
   
 

Math with a Raster and a Scalar value

For "Scalar with a Raster" we are taking a "scalar" value (e.g. a single numeric value) and using it to "operate" on a raster. An example would be adding "2" to all the values in a raster or dividing all the values in a raster by 2. Try this an other operations in the tool below.

Dimensions of the raster:

 

=
   
 

 

Raster with another Raster Math

For "Raster with another Raster" we are operating on one raster with another raster. This would include adding two rasters together or dividing the values in one raster by the values in another. Remember that these are pixel by pixel operations. Try the tool below.

Dimensions of the raster:

 

=
 
 

 

 

 

Comparisons Between Rasters

We can execute "comparisons" between two rasters and the result will be a "boolean" raster. The comparisons include; equals ("="), not equals ("!="), less than ("<"), greater than (">"), less than or equals ("<="), and greater than or equals (">="). The result of a comparison is a "Boolean" value which can only be "true" or "false". "true" is set inside the computer as a one while "false" is a zero. You can refer to boolean values as true or false or as 1 or 0. Either is correct and common.

Dimensions of the raster:

 

=
 
 

 

Boolean Operations on Rasters

Once we have a couple of boolean rasters, we can perform operations on the rasters to find where one raster contains "true" values (or 1) AND the other contains "true" values. An example would be finding where there is habitat for wolves AND habitat for deer. We can also find where one raster contains "true" values OR the other contains "true" values. Here the words "AND" and "OR" take on special meanings.

Dimensions of the raster:

 

=
 
 

Con!

The conditional function is very important in ArcGIS because it allows us to convert a particular set of pixels to another value. There are many instances when you can't use the Reclassify tool for this because it will convert your raster pixels to integer values, potentially losing a great deal of accuracy and precision. The "Con()" function in Raster Calculator takes three parameters:

Con(ConditionalRaster,TrueRasterOrScalar,FalseRasterOrScalar)

The ConditionalRaster can be an existing boolean raster with just 1s and 0s or a comparison that creates a boolean raster. The "TrueRasterOrConstant" is the value that will replace the pixels where the ConditionalRaster is TRUE. The "TrueRasterOrScalar" can be an existing raster or a scalar value. The "FalseRasterOrScalar" value will replace the pixels where the COnditionalRaster is FALSE. The "FalseRasterOrScalar" can be and existing raster or a scalar value.

Some examples include:

Raster Calculator in ArcGIS

The video below will show you how to perform some raster mathematics in ArcGIS's "Raster Calculator".

Test Your Knowledge

Next ->

© Copyright 2018 HSU - All rights reserved.